<template>
	<view class="addBox" style="min-height: 100vh;">
		<view class="m_header_top">
			<my-top @submit="subMitForm" title="重复事件添加" customClass='center_c'></my-top>
		</view>
		<view class="contentBox">
			<view class="oncetime">
				<!-- 		border-bottom: 1px solid rgba(102, 102, 102, .2); -->
				<view class="itemcnt" :style="{border:formdul.showcourse ? '1px solod rgba(102, 102, 102, .2)' : ''}">
					<view class="time1" @click="btns(formdul.showcourse,1)">
						<text class="iconfont todayri fontSize"></text>
						<text class="title">选择日程表</text>
						<text v-if="formdul.showcoursecheck">{{templatesdata.defaucourse.name}}</text>
					</view>
					<view class="downup">
						<switch :checked="formdul.showcoursecheck" @change="btncheck(formdul.showcoursecheck,1)" />
					</view>
				</view>
				<view :class="formdul.showcourse  == true?'chosetime':'chosetimehidden'">
					<!-- 	<view class="childlist">
						<view class="childbox">
							 @click="btncourse(item)"
							<view class="boxitem"> -->
					<radio-group @change="radioChange" class="radioBox">
						<label class="uni-list-cell uni-list-cell-pd radioItem" v-for="(item, index) in courselist" :key="item.value">
							<view>
								<radio :checked="templatesdata.defaucourse.id == item.id" :value="item.id.toString()" /><text>{{item.name}}</text>
							</view>

						</label>
					</radio-group>
					<!-- 	</view>
						</view>
					</view> -->
				</view>
			</view>
			<view class="oncetitle">
				<view class="iconIptBox">

					<text class="iconfont fontSize" :class="icon ? icon.icon : ''" :style="{'color':icon.color}" style="margin-left: 10rpx;"></text>
					<input :style="{'color':color}" class="myinput" v-model="templatesdata.scheduleval" @blur='getname' type="text"
					 placeholder="输入事件名称..." value="" />
				</view>
				<view class="box">
					<view @click="switchIcons" class="itemcolor">
						<text v-if="!icon.icon" :class="switchIconOk ?  switchIcon : 'todaytubiao_1' " class="iconfont fontSize"></text>
						<text v-else class="iconfont fontSize" :class="icon ? icon.icon : ''" :style="{'color':icon.color}" style="margin-left: 10rpx;"></text>
						<text>图标</text>
					</view>
					<view @click="openColorSwitch" class="itemcolor">
						<text class="iconfont todayyanse fontSize" :style="{'color':color}">
						</text>
						<!-- <text v-else class="iconfont todayyanse fontSize"></text> -->
						<text>颜色</text>
					</view>
				</view>
			</view>

			<view class="oncetime">
				<view class="itemcnt">
					<view class="time1" @click="btns(formdul.showdate,0)">
						<text class="iconfont todayshijian fontSize"></text>
						<text class="title">时间</text>
						<block v-if="formdul.showdatecheck">
							<text class="text">{{switchTime.yearMonth}}</text>
							<text class="text">{{switchTime.monthDayWeek}}</text>
							<text class="text">{{switchTime.time}}</text>
						</block>
						<text v-else class="overflowText">请选择时间</text>
					</view>
					<view class="downup">
						<switch :checked="formdul.showdatecheck" @change="btncheck(formdul.showdatecheck,0)" />
					</view>
				</view>
				<view :class="formdul.showdate  == true?'chosetime':'chosetimehidden'">
					<view class="addmethod borderbottom">
						<text v-for="(item,index) in typelist" :key='index' @click="changetype(index,item)" :class="index == formdul.defaultindex?'defultbox':''"
						 class="vdatabox">{{item}}</text>
					</view>
					<view class="switchTimeData" v-if="formdul.defaultindex===2 && classShow == false">
						<block v-for="(item,index) in switchTimeList" :key="index">
							<view class="">
								<view class="timeItem" @click="switchTimeOption(item.id)" :class="item.id == typeIndex ? 'timeItemActive':''">
									<view class="">
										{{item.name}}
									</view>
								</view>
							</view>
						</block>
						<!-- 	<view class="inputBox">
							<input :focus="focus" v-model="vdaytime" @input="ipt1" type="number" maxlength="2" />
							:
							<input :focus="focus1" v-model="vdaytime2" @input="ipt2" type="number" maxlength="2" />
						</view> -->

						<!-- <view class="inputBox">
								<input :focus="focus" v-model="vdaytime" @input="ipt1" type="number" maxlength="2" />
								:
								<input :focus="focus1" v-model="vdaytime2" @input="ipt2" type="number" maxlength="2" />
							</view> -->
					</view>
					<view class="numberTimeEnter" :style="{'border' : timeSwiperCurrent != null ? '1px solid #f08c00' : ''}" v-if="typeIndex== 1 && formdul.defaultindex===2">
						<!-- 	<input :style="{'border' : timeSwiperCurrent != null ? '1px solid #f08c00' : ''}" :maxlength="4" @focus="iptFocus1" :value="timeindex" class="timeinput" type="text" @input='changeinput' />
						<text class="colon">:</text> -->

						<input :maxlength="2" :style="{color:this.timeSwiperCurrent == 0 ? '#f08c00' : ''}" @focus="iptFocus1" :value="timeindex.startSwitch"
						 class="timeinput" type="text" @input='changeinput' />
						:
						<input :maxlength="2" :style="{color:this.timeSwiperCurrent == 1 ? '#f08c00' : ''}" @focus="iptFocus2" :value="timeindex.endSwitch"
						 class="timeinput" type="text" @input='changeinput' />
						<!-- <picker mode="time" :value="temstart" @change="bindtemstart">
														<view class="uni-input">{{temstart}}</view>
													</picker> -->
					</view>
					<view class="numberTimeEnter1" v-if="typeIndex== 2 && formdul.defaultindex===2">
						<view :style="{'border' :  timeType == 'startTime' ? '1px solid #f08c00' : ''}" class="PeriodTime1">
							<input class="PeriodTime1Ipt1" :maxlength="2" :style="{color:timeType == 'startTime' && timeKey == 'startSwitch' ? '#f08c00' : ''}"
							 @focus="PeriodStart(1,true)" :value="temstart.startSwitch" type="text" @input='changeinput' />
							<text>:</text>
							<input class="PeriodTime1Ipt1" :maxlength="2" :style="{color:timeType == 'startTime' && timeKey == 'endSwitch' ? '#f08c00' : ''}"
							 @focus="PeriodStart(2,true)" :value="temstart.endSwitch" type="text" @input='changeinput' />
						</view>
						<text>到</text>
						<view :style="{'border' : timeType == 'endTime' ? '1px solid #f08c00' : ''}" class="PeriodTime1">
							<input class="PeriodTime1Ipt1" :maxlength="2" :style="{color:timeType == 'endTime' && timeKey == 'startSwitch' ? '#f08c00' : ''}"
							 @focus="PeriodStart(1,false)" :value="temend.startSwitch" type="text" @input='changeinput' />
							<text>:</text>
							<input class="PeriodTime1Ipt1" :maxlength="2" :style="{color:timeType == 'endTime' && timeKey == 'endSwitch' ? '#f08c00' : ''}"
							 @focus="PeriodStart(2,false)" :value="temend.endSwitch" type="text" @input='changeinput' />
						</view>
						<!-- <input :maxlength="4" v-model="vdaytime" class="timeinput" type="number" @input='changeinput' />
						到
						<input :maxlength="4" v-model="vdaytime" class="timeinput" type="number" @input='changeinput' /> -->
					</view>
					<!-- 年月 -->
					<view class="" v-if="formdul.defaultindex === 0 ">
						<my-year class="timeyears" @selectyear='getyear' ref="years"></my-year>
					</view>
					<!-- 日期 -->
					<view class="" v-if="formdul.defaultindex === 1">
						<Calendar :timeStr="switchTime.yearMonth" @dchange="dchange" v-show="!isyear" ref="calendar" class='month'
						 @selected-change='dayChange'></Calendar>
					</view>
					<!-- <view class="allDay" v-if="formdul.defaultindex ===2 && classShow == false">
						全天事件将会出现在今日视图中,您可选择任意时间执行
					</view> -->
					<view v-show="classShow">
						<view class="change">
							<i class="iconfont todayshouye iconsize" @click='prev'></i>
							<text @click="changeyear">{{templates.date}}</text>
							<i class="iconfont todayshouye iconsize" @click='next'></i>
						</view>
					</view>
				</view>

			</view>

			<view class="oncetime ">
				<view class="itemcnt column">
					<view class="time1">
						<text class="iconfont todayzhongfu1 fontSize"></text>
						<text class="title">重复</text>
						<text class="overflowText" @click="editSwitchRepeat" v-if="switchOpen">{{customRepeat.name}}</text>
						<text class="overflowText" v-else>请选择重复</text>
					</view>
					<view class="downup">
						<switch :checked="switchOpen" @change="switchRepeat" />
					</view>

				</view>
				<view class="itemcnt ">
					<view class="time1">
						<i class="iconfont todaybuzhongfu fontSize"></i>
						<text class="title">结束重复</text>
						<text class="overflowText" @click="editEndRepeat" v-if="endOpen">{{endTimeNumber ? endTimeNumber.value : '请选择'}}</text>
						<text class="overflowText" v-else>请选择结束重复日期</text>
					</view>
					<!-- @click="btns(formdul.showpublic,2)" -->
					<view class="downup">
						<switch :checked="endOpen" @change="endRepeat" />
					</view>

				</view>
				<view :class="formdul.showpublic == true?'chosetime':'chosetimehidden'">
					<view class="public">
						<view class="item" :class="item.name==templatesdata.defaupublic?'defauitem':''" @click="btnchosename(item.name)"
						 v-for="(item,index) in checkdata" :key='index'>
							{{item.name}}
						</view>
					</view>
				</view>
			</view>



			<!-- <view class="oncetime">
				<view class="itemcnt">
					<view class="time1" @click="btns(formdul.showpublic,2)">
						<i class="iconfont todaysimi4 "></i>
						<text class="title">公开范围</text>
						<text v-if="formdul.showpublicheck">{{templatesdata.defaupublic}}</text>
					</view>
					<view class="downup">
						<switch color="#6BDFA4" :checked="formdul.showpublicheck" @change="btncheck(formdul.showpublicheck,2)" />
					</view>
				</view>
				<view :class="formdul.showpublic == true?'chosetime':'chosetimehidden'">
					<view class="public">
						<radio-group @change="btnchosename" class="openRange">
							<label v-for="(item, index) in checkdata" :key="item.value" class="item uni-list-cell uni-list-cell-pd openRangeIem">
								<view>
									<radio :value="item.id.toString()" /><text style="font-size: 24rpx;margin-left: 16rpx;">{{item.name}}</text>
								</view>
							</label>
						</radio-group>
					</view>
				</view>
			</view> -->

			<block v-if="leftlist.length>0">
				<view class="oncetime" v-for="(item,index) in leftlist" :key='index'>
					<view class="itemcnt">
						<view class="time1">
							<block v-for="ele in icons">
								<text :class="ele.ids == item.ids ? ele.icon : ''" class="iconfont"></text>
							</block>
							<text class="title">{{item.name}}</text>
							<view class="overflowText" v-if="item.ids == 2">
								<text>提前</text>
								<block v-for="(items,index1) in item.title" :key="index1">
									<text>{{items}}</text>
								</block>
								<text></text>
							</view>
							<view class="contactBox" v-else-if="item.ids == 3">
								<block v-for="items in item.title" >
									<view class="contactBorder" @click="callPhone(items)">
										{{items.name ? items.name.split("")[0]  : ""}}
									</view>
								</block>
							</view>
							<view class="overflowText" v-else-if="item.ids != 4">{{item.title}}</view>
						</view>
						<view @click="btnleftchose(item,index)" class="downup">
							<i class="iconfont todayquxiao iconsize2"></i>
						</view>
					</view>
					<view v-if="item.ids == 1" :class="formdul.showpublic == false?'chosetime':'chosetimehidden'">
						<view class="public">
							<view class="page-section page-section-gap">
								<map :style="{'width':720+'rpx','height':320+'rpx'}" :markers="markers[0]" :latitude="latitude[1]" :longitude="longitude[1]">
								</map>
							</view>
						</view>
					</view>
					<view class="" v-if="item.ids == 4">
						<my-show-media :list="item.dataZ"></my-show-media>
					</view>
				</view>
			</block>
			<view class="oncetime" v-if="rightlist.length>0">
				<view class="itemcnt">
					<view class="time2" @click="btnrightchose(item,index)" v-for="(item,index) in rightlist" :key='index'>
						<block v-for="ele in icons">
							<text :class="ele.ids == item.ids ? ele.icon : ''" class="iconfont fontSize"></text>
						</block>
						<text class="title">{{item.name}}</text>
					</view>
				</view>
			</view>
		</view>
		<diaLog ref="dialog" direction="center" :is_close="false" :is_mask="true" :width="95">
			<view class="colorBox">
				<view :class="item.check ? 'color-check' : ''" :key="index" @click="switchColor(item)" class="itemP" v-for="(item,index) in colorList">
					<view class="colorItem" :style="{'background':item.color}">
					</view>
				</view>
			</view>
		</diaLog>
		<diaLog ref="dialogIcons" direction="center" :is_close="false" :is_mask="true" :width="95">
			<view class="colorBox">
				<view :class="item.check ? 'color-check' : ''" :key="index" @click="switchColor(item)" class="itemP" v-for="(item,index) in iconList">
					<text style="font-size: 36rpx;" class="iconfont" :class="item.icon" :style="{'color':item.color}"></text>
				</view>
			</view>
		</diaLog>
		<my-popup ref="switchPopup" type="bottom" :maskClick="false" :animation="true">
			<view class="uni-padding-wrap">
				<view class="page-section swiper">
					<view class="page-section-spacing">
						<swiper :current="swiperCurrent" style="min-height: 100vh;" :disable-touch="true" class="swiper" :interval="2000"
						 :duration="500">
							<swiper-item>
								<my-switchRepeat @custom="switchCustomRepeat" @switchRepeatBack="switchRepeatBack" @success="switchRepeatSuccess"
								 :year="currentTime"></my-switchRepeat>
							</swiper-item>
							<swiper-item>
								<my-customRepeat @success="customSuccess" @customCancel='customCancel' :year="currentTime"></my-customRepeat>
							</swiper-item>
						</swiper>
					</view>
				</view>
			</view>
		</my-popup>

		<my-popup ref="endPopup" type="bottom" :maskClick="false" :animation="true">
			<my-endRepeat @success="endRepeatSuccess" @endBack="endBack"></my-endRepeat>
		</my-popup>

		<my-popup ref="remindPopup" type="bottom" :maskClick="false" :animation="true">
			<my-remind @back="remindBack" @sucess="remindScuess" :ids="optionId"></my-remind>
		</my-popup>


		<my-popup ref="addNotePopup" type="bottom" :maskClick="false" :animation="true">
			<!-- <my-addNote @back="addNoteBack" @sucess="addNoteSucess" :ids="optionId"></my-addNote> -->
			<view class="invoice-popup-content">
				<view class="mymedia">
					<my-media @resultMedia="resultMedia" @changemedia='mediaBack'></my-media>
				</view>
			</view>
		</my-popup>
		<my-popup ref="numberInput" type="bottom" :maskClick="true" :animation="true">
		</my-popup>
		<my-popup @change="popupChange" ref="numberIptKey" type="bottom" :maskClick="true" :animation="true">
			<view class="uni-padding-wrap">
				<view class="page-section swiper">
					<view class="page-section-spacing">
						<swiper style="height: 400rpx;" :current="timeSwiperCurrent" :disable-touch="true" class="swiper" :interval="2000"
						 :duration="500">
							<swiper-item style="display: flex;flex-direction: column-reverse;">
								<my-numberIptKey @clickNumerKey="clickNumerKey"></my-numberIptKey>
							</swiper-item>
							<swiper-item style="display: flex;flex-direction: column-reverse;">
								<my-numberInputMethod @del="iptDel()" @iptNumber="numberInputMethod"></my-numberInputMethod>
							</swiper-item>
						</swiper>
					</view>
				</view>
			</view>
		</my-popup>
		<my-popup ref="pptUser" type="bottom" :maskClick="false" :animation="true">
			<my-participants :ids="optionId" @pptUserSucess="pptUserSucess" @back="pptUserBack"></my-participants>
		</my-popup>
	</view>
</template>

<script>
	import diaLog from "@/components/ming-pop/ming-pop.vue"
	import Calendar from '@/components/zzx-calendar/zzx-calendar.vue';
	import moment from "moment"
	import {
		scheduleTbAdd,
		repeatAddTwo,
		repeatWeekAdd,
		calculatetime,
		searchScheduleInfo,
		typeEdit
	} from "@/api/api.js"

	import {
		set,
		get
	} from "@/utils/addOne.js"
	// import dragSorts from '@/components/HM-dragSorts/HM-dragSorts.vue'
	import {
		mapState,
		mapGetters
	} from 'vuex'
	import {
		selectByuserIdList
	} from "@/api/api.js"
	export default {
		components: {
			// 'HM-dragSorts': dragSorts
			Calendar,
			diaLog
		},
		created() {
			this.currentTime = moment().format('YYYY-MM-DD');
		},
		data() {
			return {
				timeSwiperCurrent: null, //选择时间轮播
				switchTimeList: [{
						id: 1,
						name: '时间点'
					},
					{
						id: 2,
						name: '时间段'
					},
					{
						id: 3,
						name: '全天'
					}
				],
				optionId: '', //可选项列表的id
				focus: false,
				focus1: false,
				SAVE_YEAR: 5,
				vdaytime2: "",
				vdaytime: ':',
				icon: {}, //选择的icon
				iconList: [{
						id: 1,
						check: false,
						icon: "todayxuexi",
						color: "rgba(252, 98, 96, 1)"
					},
					{
						id: 2,
						check: false,
						icon: "todayxuexi",
						color: "rgba(255, 180, 105, 1)"
					},
					{
						id: 3,
						check: false,
						icon: "todayxuexi",
						color: "rgba(107, 223, 164, 1)"
					},
					{
						id: 4,
						check: false,
						icon: "todayxuexi",
						color: "rgba(254, 148, 192, 1)"
					},
					{
						id: 5,
						check: false,
						icon: "todayshenghuo",
						color: "rgba(198, 175, 255, 1)"
					},
					{
						id: 6,
						check: false,
						icon: "todayshenghuo",
						color: "rgba(180, 228, 255, 1)"
					},
					{
						id: 7,
						check: false,
						icon: "todayshenghuo",
						color: "rgba(255, 205, 141, 1)"
					},
					{
						id: 8,
						check: false,
						icon: "todayshenghuo",
						color: "rgba(153, 153, 153, 1)"
					}
				],
				switchIconOk: "",
				colorList: [{
						id: 1,
						color: "#6BDFA4",
						check: false
					},
					{
						id: 2,
						color: "#FE94C0",
						check: false
					},
					{
						id: 3,
						color: "#9AB1FF",
						check: false
					},
					{
						id: 4,
						color: "#FED28B",
						check: false
					},
					{
						id: 5,
						color: "#FF94EF",
						check: false
					},
					{
						id: 6,
						color: "#75E2EA",
						check: false
					},
					{
						id: 7,
						color: "#999999",
						check: false
					},
					{
						id: 8,
						color: "#FFA9A9",
						check: false
					},
				],
				isrepeat: 2, //1：一次，2:重复
				title: 'map',
				// latitude: '31.18826',
				// longitude: "121.43687",
				covers: [],
				option: {},
				isyear: false,
				dateyear: '',
				checkdata: [{
						name: '全部',
						id: 1,
					},
					{
						name: '好友可见',
						id: 2,
					},
					{
						name: '自己可见',
						id: 3,
					},
				],
				courselist: [{
						name: '我的日程1',
						id: 1,
					},
					{
						name: '我的日程2',
						id: 2,
					},
					{
						name: '我的日程3',
						id: 2,
					},
					{
						name: '我的日程4',
						id: 2,
					},
					{
						name: '我的日程5',
						id: 2,
					},
				],
				classShow: false,
				templatesdata: {
					// 标题
					scheduleval: '',
					// 日程表
					defaucourse: '',
					// 公开范围
					defaupublic: '',
					longitude: '',
					latitude: '',
					classAddress: ""
				},
				// formdul: {
				// 	showcourse: false,
				// 	showcoursecheck: false,
				// 	showdatecheck: false,
				// 	showpublic: false,

				// 	showindex: false,
				// 	defaultindex: 0,
				// 	showdate: false,

				// },
				templates: {
					day: '',
					week: '',
					years: '',
					date: '',
					time: ''
				},
				mark: [{
						time: '2019-8-23',
						text: '标记',
						markPoint: true,
						markTextColor: 'blue',
						pointText: '奖',
						pointTextColor: 'red'
					},
					{
						time: '2019-8-24',
						text: '上山打老虎',
						markPoint: true,
						pointText: '2',
					}
				],
				range: {
					rangeStart: undefined, //设置标记范围开始，yyyyMM-dd
					rangeEnd: undefined //设置标记范围结束，yyyyMM-dd
				},
				rangeMode: false,
				currentTime: '',
				title: 'Hello',
				dateStart: '2019-6-15',
				dateEnd: '2020-6-15',
				time: '06:00',
				color: "", //选择的颜色
				year: "",
				swiperCurrent: 0,
				typelist: [],
				switchTime: {
					yearMonth: "",
					monthDayWeek: "",
					time: ""
				},
				timeType: 'timePoint',
				timeKey: "startSwitch"
			};
		},
		onBackPress() {
			uni.showModal({
			    title: '未选择参与者',
			    content: '确定退出吗',
			    success: function (res) {
			        if (res.confirm) {
			        } else if (res.cancel) {
						
			        }
			    }
			});
		},
		watch: {
			leftlist: {
				handler(val) {
					console.log(val);
				},
			},
			templates: {
				handler(val) {
					this.saverval(6, val)
				},
				// 深度监听
				deep: true,

				// 该回调将会在侦听开始之后被立即调用
				immediate: true
			},
			// vdaytime: {
			// 	handler(val) {
			// 		if (val.length > 5) {
			// 			val = val.substr(0, 4)
			// 		}
			// 		// this.formdate(val);
			// 	},
			// 	// 深度监听
			// 	deep: true,
			// 	// 该回调将会在侦听开始之后被立即调用
			// 	immediate: true
			// }
		},
		onLoad(option) {
			option.id ? this.initEdit(option.id, option.typeChild) : this.initOnLoad()
		},
		computed: {
			...mapState('repeatAdd', {
				switchOpen: state => state.repeats.switchs,
				endOpen: state => state.repeats.end,
				typeIndex: state => state.timeData.typeIndex,
				formdul: state => state.formdul,
				temstart: state => state.timeData.startTime,
				temend: state => state.timeData.endTime,
				timeindex: state => state.timeData.timePoint,
				icons: state => state.icons,
				endTimeNumber: state => state.endTimeNumber, //结束时间
				rightlist: state => state.rightlist,
				leftlist: state => state.leftlist,
				addForm: state => state.data,
				customRepeat: state => state.customRepeats, //自定义重复数据
				latitude: state => state.data.map(ele => {
					if (ele.ids == 1) {
						return ele.data.latitude
					}
				}),
				longitude: state => state.data.map(ele => {
					if (ele.ids == 1) {
						return ele.data.longitude
					}
				}),
				//地图标识点
				markers: state => state.data.map((item, index) => {
					if (item.ids == 1) {
						var covers = [{
							id: 1,
							latitude: item.data.latitude,
							longitude: item.data.longitude,
							iconPath: "../../../../static/img/Feedback.png"
						}]
						console.log(covers, "位置");
						return covers
					}
				})
			}),
		},
		methods: {
			// 参与人拨打电话
			callPhone(val){                                      
				uni.makePhoneCall({
				    phoneNumber:val.phone 
				});
			},
			pptUserSucess() {
				this.$refs.pptUser.close()
			},
			pptUserBack() {
				this.$refs.pptUser.close()
			},
			//添加备注完成
			resultMedia(val) {
				this.saverval(4, val)
				this.$refs.addNotePopup.close()
			},
			//添加备注取消
			mediaBack() {
				this.$refs.addNotePopup.close()
			},
			// 编辑进入初始化
			async initEdit(id, typeChild) {
				const result = await searchScheduleInfo({
					id: Number(id),
					typeChild: Number(typeChild)
				});
				if (result.statusCode == 200 && result.data.code == 0) {
					let resolve = result.data.data;
					this.templatesdata.scheduleval = resolve.title;
					this.switchTime.yearMonth = moment(resolve.issueTime).format("YYYY年MM月");
					this.switchTime.monthDayWeek = moment(resolve.issueTime).format("MM/DD") + '/' + this.filterWeekName(moment(
						resolve.issueTime).format('YYYY-MM-DD'));
					let startTime = resolve.startTime.split(":")[0] + ':' + resolve.startTime.split(":")[1];
					let endTime = resolve.endTime.split(":")[0] + ':' + resolve.endTime.split(":")[1];
					this.switchTime.time = startTime + '-' + endTime;
					this.typelist.push(this.switchTime.yearMonth, this.switchTime.monthDayWeek, this.switchTime.time)
					this.color = result.data.data.color;
					//设置vuex数据
					this.$store.commit("repeatAdd/editSetData", result.data.data);
				}
			},
			//进入添加页面初始化操作
			initOnLoad() {
				let a = moment()
				if (uni.getStorageSync('templates')) {
					this.templates = uni.getStorageSync('templates')
				} else {
					this.templates.week = this.filterWeekName(a.format('YYYY-MM-DD'));
					this.templates.day = a.format('MM/DD');
					this.templates.date = a.format('YYYY年MM月')
					this.templates.years = a.format('YYYY-MM-DD');
					this.year = a.format('YYYY-MM-DD');

				}
				this.switchTime.yearMonth = a.format("YYYY年MM月");
				this.switchTime.monthDayWeek = a.format("MM/DD") + '/' + this.filterWeekName(a.format('YYYY-MM-DD'));
				this.switchTime.time = a.format("HH:mm");
				for (let i in this.switchTime) {
					this.typelist.push(this.switchTime[i])
				}
				this.initdata()
			},
			/* 
				时间段
				@params:1：小时，2：分钟 type:开始or结束
			 */
			PeriodStart(index, type) {
				uni.hideKeyboard(); //隐藏软键盘
				type ? this.timeType = 'startTime' : this.timeType = 'endTime'
				if (index == 1) {
					this.timeKey = 'startSwitch'
					this.timeSwiperCurrent = 0;
				} else {
					this.timeKey = 'endSwitch'
					this.timeSwiperCurrent = 1;
				}
				this.$refs.numberIptKey.open();
			},
			popupChange(e) {
				e.show ? '' : this.timeSwiperCurrent = null;
				let str = null;
				this.timeType == 'timePoint' ? str = this.timeindex : (this.timeType == 'startTime' ? str = this.temstart : str =
					this.temend)
				if (!e.show) {
					if (str.endSwitch.split("")[0] >= 6) {
						let strTime = '0';
						this.$store.commit("repeatAdd/setTime", {
							type: this.timeType,
							key: 'endSwitch',
							value: strTime + str.endSwitch.split("")[1].toString()
						});
					}
					if (this.timeType == 'timePoint') {
						this.switchTime.time = str.startSwitch + ':' + str.endSwitch
					} else if (this.timeType == 'endTime') {
						this.switchTime.time = this.temstart.startSwitch + ':' + this.temstart.endSwitch + '—' + str.startSwitch + ':' +
							str.endSwitch;
					}
					this.timeType = 'timePoint';
					this.timeKey = 'startSwitch';
					this.typelist.splice(2, 1, this.switchTime.time)
				}
			},
			iptDel() {
				let str = null;
				this.timeType == 'timePoint' ? str = this.timeindex : (this.timeType == 'startTime' ? str = this.temstart : str =
					this.temend)
				if (str.endSwitch != '00') {
					this.$store.commit("repeatAdd/delTimeDate", {
						type: this.timeType,
						key: 'endSwitch'
					});
				}
			},
			clickNumerKey(val) {
				this.$store.commit("repeatAdd/setTime", {
					type: this.timeType,
					key: this.timeKey,
					value: val
				});
				this.timeKey = 'endSwitch';
				this.timeSwiperCurrent = 1;
			},
			iptFocus2() {
				uni.hideKeyboard(); //隐藏软键盘  
				this.timeSwiperCurrent = 1;
				this.timeKey = 'endSwitch'
				this.$refs.numberIptKey.open()
			},
			iptFocus1() {
				uni.hideKeyboard(); //隐藏软键盘  
				this.timeSwiperCurrent = 0;
				this.timeKey = 'startSwitch'
				this.$refs.numberIptKey.open()
			},
			numberInputMethod(value) {
				let str = null;
				this.timeType == 'timePoint' ? str = this.timeindex : (this.timeType == 'startTime' ? str = this.temstart : str =
					this.temend)
				if (str.endSwitch != '00' && str.endSwitch.toString().length >= 2) {
					return
				}
				this.$store.commit("repeatAdd/setTime", {
					type: this.timeType,
					key: this.timeKey,
					value: (str.endSwitch != '00' ? str.endSwitch.toString() : '') + value.name.toString()
				});
			},
			//选择时间点，时间段，全天
			switchTimeOption(index) {
				index == 2 ? this.timeType = "startTime" : (index == 1 ? this.timeType = 'timePoint' : '')
				this.$store.commit("repeatAdd/setFormdulTimeIndex", index);
				this.$store.commit("repeatAdd/setTimeData", {
					typeIndex: index
				})
			},
			// 日程表选择
			radioChange(val) {
				let item = this.courselist.find(ele => {
					if (ele.id == val.detail.value) {
						return ele
					}
				})
				this.templatesdata.defaucourse = item;
				this.saverval(7, item);
				this.btns(false, 1)
			},
			ipt1(val) {
				this.inputChange(this.vdaytime, true)
			},
			ipt2(val) {
				this.inputChange(this.vdaytime2, false)
			},
			inputChange(num, ele) {
				// 第一个输入框
				var str = num.toString()
				if (ele) {
					if (str.length == 2) {
						if (num == 24) {
							this.vdaytime = "00";
						} else {
							let string1 = str.split("");
							if (string1[0] > 2) {
								this.vdaytime = "0" + string1[1]
							}
						}
						this.focus = false;
						this.focus1 = true;
					}
				} else {
					//第二个
					if (str.length == 2) {
						let string1 = str.split("");
						if (string1[0] >= 6) {
							this.vdaytime2 = "0" + string1[1]
						}
						this.focus1 = false;
					}
				}
				this.switchTime.time = this.vdaytime + ':' + this.vdaytime2;
				this.typelist.splice(2, 1, this.switchTime.time)
			},

			// 改变输入
			changeinput(e) {
				// if(vdaytime.toString().length > 4){
				// 	return
				// }

				this.formdate(e.detail.value.toString())
				// let value = e.detail.value;
			},
			formdate(value) {
				if (value.length == 2) {
					let t1 = value.substr(0, 1);
					let t2 = value.substr(1, 1);
					if (t1 > 6) {
						t1 = 0
					}
					this.vdaytime = t1 + t2;
				} else if (value.length == 4) {
					let t1 = value.substr(0, 1);
					let t2 = value.substr(1, 1);
					let t3 = value.substr(2, 1);
					let t4 = value.substr(3, 1);
					// console.log('时间',t1,t2,t3,t4);
					if (t1 > 2)
						t1 = 0
					if (t3 > 5)
						t3 = 0
					this.vdaytime = t1 + t2 + t3 + t4;
				} else if (value.length > 4) {
					// let t1 = value.substr(0, 1);
					// let t2 = value.substr(1, 1);
					// let t3 = value.substr(2, 1);
					// let t4 = value.substr(3, 1);
					// let t5 = value.substr(4, 1);
					// if (t2 > 2)
					// 	t2 = '0'
					// // 04567
					// if (t4 > 5)
					// 	t4 = '0'
					// // if(t5>9)
					// // t3 = 0
					// console.log('t2', t2);

					// this.vdaytime = t2 + t3 + t4 + t5;
				} else {
					// this.vdaytime = '0000'
				}
			},
			// 选择图标
			switchIcons() {
				this.$refs.dialogIcons.show()
			},
			// 点击颜色
			switchColor(item) {
				if (item.icon) {
					this.iconList.map(ele => {
						ele.check = false
						if (item.id == ele.id) {
							ele.check = true
							setTimeout(() => {
								this.icon = {
									icon: item.icon,
									color: item.color
								};
								this.$refs.dialogIcons.close()
							}, 500)
						}
					})
				} else {
					this.colorList.map(ele => {
						ele.check = false
						if (item.id == ele.id) {
							ele.check = true
							setTimeout(() => {
								this.color = item.color;
								this.$refs.dialog.close()
							}, 500)
						}
					})
				}

			},
			// 打开颜色选择器
			openColorSwitch() {
				this.$refs.dialog.show()
			},
			async initdata() {
				let result = await selectByuserIdList({
					userId: 27
				})
				if (result.data.code == 0 && result.data.data.length > 0) {
					this.courselist = result.data.data;
				} else {
					console.log('没有数据')
				}
				console.log(result)
			},
			getname(e) {
				console.log('val', e.target.value);
				this.templatesdata.scheduleval = e.target.value;
				this.saverval(5, this.templatesdata.scheduleval)
			},
			getdata() {
				let data = JSON.parse(JSON.stringify(this.addForm));
				if (data.length > 0) {
					data.map(v => {
						switch (v.ids) {
							case 4:
								this.templatesdata = Object.assign(this.templatesdata, { ...v
								});
								break;
							case 2:
								this.templatesdata.notify = v.data.name;
								break;
							case 5:
								this.templatesdata.scheduleval = v.data;
								break;
							case 1:
								this.templatesdata.latitude = v.data.latitude;
								this.templatesdata.longitude = v.data.longitude;
								this.templatesdata.classAddress = v.data.name;
								break;
							case 7:
								this.templatesdata.defaucourse = v.data;
								break
							case 8:
								this.templatesdata.defaupublic = v.data.name;
								break;
							case 6:
								this.templatesdata.templates = v.data;
								break;
							default:
								return false
						}
					})
				}
				this.templatesdata = Object.assign(this.templatesdata, this.customRepeat);
			},
			saverval(id, data) {
				let obj = {
					ids: id,
					data
				}
				this.$store.commit("repeatAdd/pushData", obj)
			},
			// 结束重复判断
			endRepeatJudge(endType) {
				switch (endType) {
					case 1:
						break;
					case 2:
						break;
					case 3:
						break;
				}
			},
			everyYearOnce(startDate, endType) {
				let theStartTime = Number(moment(startDate).format("YYYY"))
				let monthDay = moment(startDate).format("MM-DD")

				function isLeapYear(endTime, isrun) {
					let count = 0; //如果他不是闰年，次数加一
					let num = 0;
					for (let i = theStartTime; i < endTime; i++) {
						let res = moment([i]).isLeapYear();
						if (isrun && res) {
							count += 1;

						} else {
							num += 1;
						}
					}
					return count
				}
				switch (endType) {
					case 1:
						if (monthDay == '02-29') {
							console.log("是"); // 闰年加
							return isLeapYear(theStartTime + this.SAVE_YEAR, true)
						} else {
							// 不是闰 直接retun
							return this.SAVE_YEAR;
						}
						break;
					case 2:
						// 结束时间
						let theEndTime = this.endTimeNumber.value; //需要加判断
						let momentMonthDay = moment(theEndTime).format("MM-DD")
						if (theStartTime < theEndTime && momentMonthDay > monthDay) {
							// 开始时间是不是闰年2-29？
							if (monthDay == '02-29') {
								return isLeapYear(theEndTime.split("-")[0], true)
							} else {
								return theEndTime.split("-")[0] - theStartTime;
							}
						} else if (theStartTime < theEndTime && momentMonthDay < monthDay) {
							return (Number(theEndTime.split("-")[0]) - Number(theStartTime)) - 1;
						} else {
							return 0
						}
						break;
					case 3:
						return this.endTimeNumber.value;
						break;
				}

			},
			//计算重复自定义日期---次数
			sunCalculate(startDate, endType) {
				const nowTime = moment().format("YYYY-MM-DD");
				const year = moment(startDate).format("YYYY-MM");
				const dateMonth = moment(startDate).format("MM-DD");
				let dateList = this.customRepeat.sdate;
				let arrDateList = [],
					endDateList = [];

				dateList.map((item, index) => {
					let date = year + '-' + (item < 10 ? '0' + item : item);
					let noYear = startDate.split("-")[1] + '-' + startDate.split("-")[2]
					// 选择的日期大于现在的日期
					if (date >= nowTime) {
						arrDateList.push(date)
					} else {
						endDateList.push(date)
					}
				})

				switch (endType) {
					case 1: // 永不结束
						let t2 = moment(startDate).add(this.SAVE_YEAR, "year")
						let t1 = '';
						if (startDate < nowTime) {
							t1 = moment(nowTime)
						} else {
							t1 = moment(startDate)
						}
						// console.log(t2.diff(t1, 'day'));//实际相差多少天，就计算成多少天，以下类推
						let b = t2.diff(t1, "month");
						// 继续
						return dateList.length * b - endDateList.length
						break;
					case 2: // 按日期结束
						let endDate = this.endTimeNumber.value; //结束日期

						break;
					case 3: //按次数重复
						return this.endTimeNumber.value
						break;
				}
			},
			// 计算次数
			calculationNum() {
				const endType = Number(this.endTimeNumber.id); //1:永不结束 2：按日期 3：按次数
				let NUMBER_NUM = null;
				const startDate = this.templatesdata.years; //开始日期
				// 重复日程添加  frequency 重复周期 1:每天 2:每周 3:每两周  userDefine 自定义周期（1（星期天）-7（星期六）
				const userDefine = this.customRepeat.userDefine
				const reType = Number(this.customRepeat.reType); //重复类型reType=1每月第几个周几，reType = 2每年的几月几日，reType=3自定义每月几日(阳历)，reType=4每月几日(农历)
				if (reType) {
					switch (reType) {
						// 每月第几个周几 ? 本月第几周下月不一定存在	
						case 1:
							NUMBER_NUM = this.endRepeatJudge(endType)
							break;
							// 每年的几月几日
						case 2:
							NUMBER_NUM = this.everyYearOnce(startDate, endType);
							break;
							// 自定义每月几日 阳历
						case 3:
							NUMBER_NUM = this.sunCalculate(startDate, endType)
							break;
							// 每月几日 农历
						case 4:
							break;
					}
					//周重复
				} else if (userDefine) {

				}
				console.log(NUMBER_NUM, "重复次数。。。。。。。。。。。。。。。。。");
				return NUMBER_NUM
			},
			// 数据合并
			async combine() {
				this.getdata()
				let timeJudge = null; //时间段为true，时间点为false
				this.templatesdata = Object.assign(this.templatesdata, this.templates);
				// 结束日期 结束时间  持续时间 计算
				if (this.typeIndex == 1) {
					// 时间点
					timeJudge = false
					this.templatesdata.finish_time = this.templatesdata.years;
					var startTime = this.timeindex.startSwitch + ':' + this.timeindex.endSwitch;
					var endTime = startTime;
					var duration = 0;
				} else if (this.typeIndex == 2) {
					timeJudge = true;
					// 时间段
					var duration1 = this.temstart.startSwitch + ':' + this.temstart.endSwitch.split(":");
					var duration2 = this.temend.startSwitch + ':' + this.temend.endSwitch.split(":");
					// 如果开始时间大于结束时间 跨天时间处理
					if (this.temstart.startSwitch + ':' + this.temstart.endSwitch > this.temend.startSwitch + ':' + this.temend.endSwitch) {
						let a = moment(this.templatesdata.years, "YYYY-MM-DD")
						var hours = (24 - Number(duration1[0])) + Number(duration2[0]);
						var minutes = Number(duration1[1]) - Number(duration2[1])
						this.templatesdata.finish_time = a.add(1, "days").format("YYYY-MM-DD")
					} else {
						// 开始时间小于结束时间处理
						var hours = Number(duration2[0]) - Number(duration1[0])
						var minutes = Number(duration1[1]) - Number(duration2[1])
						this.templatesdata.finish_time = this.templatesdata.years;
					}
				} else if (this.typeIndex == 3) {
					// 全天 开始时间00-23:59 开始日期结束日期一致
					timeJudge = false;
					this.templatesdata.finish_time = moment(this.templatesdata.years).add(1, "day").format("YYYY-MM-DD")
					var startTime = "00:00"
					var endTime = "00:00"
					var duration = 1439;
				}
				// 结束重复
				// var num = await this.calculationNum();
				let obj = {
					scheduleType: this.isrepeat, //1：一次性，2重复性
					userId: 20, // uni.getStorageSync("userId")
					name: this.templatesdata.scheduleval, //标题
					color: this.color, //颜色
					issueTime: this.templatesdata.years, //开始日期
					finishTime: this.endTimeNumber.id == 2 ? this.endTimeNumber.value : moment(this.templatesdata.years).add(this.SAVE_YEAR,
						"year").format("YYYY-MM-DD"), //结束日期
					startTime: timeJudge ? this.temstart.startSwitch + ':' + this.temstart.endSwitch : startTime, //开始时间
					endTime: timeJudge ? this.temend.startSwitch + ':' + this.temend.endSwitch : endTime, //结束时间
					// startTime: "09:00",
					// endTime: "10:00",
					duration: timeJudge ? (hours * 60 + minutes).toString() : duration.toString(), //持续时间
					latitude: this.templatesdata.latitude, //纬度
					longitude: this.templatesdata.longitude, //经度
					classAddress: this.templatesdata.classAddress, //地址
					notify: this.templatesdata.notify, //提前多久提醒
					reType: this.customRepeat.reType, //选择重复
					sdate: this.customRepeat.sdate,
					frequency: this.customRepeat.frequency,
					userDefine: this.customRepeat.userDefine,
					skipFlag: this.customRepeat.skipFlag ? this.customRepeat.skipFlag : 2,
					num: this.endTimeNumber.id == 3 ? this.endTimeNumber.value : 1, //重复次数
					childId: this.templatesdata.defaucourse.id,
					bvideo: this.templatesdata.data ? this.templatesdata.data.bvideo : '',
					bvoice: this.templatesdata.data ? this.templatesdata.data.bvoice : '',
					picture: this.templatesdata.data ? this.templatesdata.data.picture : '',
					remark: this.templatesdata.data ? this.templatesdata.data.standby3 : '',
					// remark
					//1-时间点 2-时间段 3-全天
					stype: this.typeIndex
					// type:this.templatesdata.data.type
				}
				console.log(obj)
				return obj;
			},
			repeatWeekAddFn(Ele) {
				let obj = {
					issueTime: Ele.issueTime,
					startTime: Ele.startTime,
					duration: Ele.duration,
					frequency: Ele.frequency ? Ele.frequency : null,
					userDefine: Ele.userDefine ? Ele.userDefine : null,
					num: Ele.num
				}
				for (let i in obj) {
					if (!obj[i]) {
						delete obj[i]
					}
				}
				if (obj.frequency) {
					repeatWeekAdd(Ele).then(res => {
						console.log(res, "res");
					})
				} else {
					calculatetime(obj).then(res => {
						if (res.statusCode == 200 && res.data.code == 0) {
							Ele.finishTime = res.data.data.finishTime;
							repeatWeekAdd(Ele).then(res => {
								console.log(res, "res");
							})
						}
					})
				}


			},
			repeatAddTwoFn(Ele) {
				repeatAddTwo(Ele).then(res => {
					console.log(res);
				})
			},
			//添加
			async subMitForm() {
				let obj = await this.combine();
				for (var i in obj) {
					if (!obj[i]) {
						if (i != 'duration') {
							delete obj[i]
						}
					}
				}
				//如果是农历，开始时间改为农历
				if (obj.reType && obj.reType == 4) {
					obj.issueTime = this.customRepeat.issueTime
				}
				if (obj.scheduleType == 1) {
					// 一次性
					this.scheduleTbAddfFn(obj)
				} else {
					// 重复性
					if (obj.frequency || obj.userDefine) {
						this.repeatWeekAddFn(obj)
					} else if (obj.reType) {
						this.repeatAddTwoFn(obj)
					}
				}

			},
			//一次性添加
			scheduleTbAddfFn(Ele) {
				scheduleTbAdd(Ele).then(res => {
					if (res.statusCode == 200 && res.data.code == 0) {
						console.log(res);
					}
				})
			},
			//自定义重复取消时间
			customCancel() {
				this.swiperCurrent = 0; //轮播位置
			},
			switchCustomRepeat() {
				this.swiperCurrent = 1;
			},
			// 取消选择重复
			switchRepeatBack() {
				if (this.switchOpenShow) {
					this.$store.commit("repeatAdd/SwitchRepeact", true);
				} else {
					this.$store.commit("repeatAdd/SwitchRepeact", false);
				}
				this.$refs.switchPopup.close();
			},
			//自定义重复完成
			customSuccess() {
				this.switchOpenShow = true;
				this.$store.commit("repeatAdd/SwitchRepeact", true)
				this.$refs.switchPopup.close();
			},
			//打开编辑选择重复
			editSwitchRepeat() {
				this.$refs.switchPopup.open();
			},
			//选择重复完成
			switchRepeatSuccess() {
				this.switchOpenShow = true;
				this.$store.commit("repeatAdd/SwitchRepeact", true)
				this.$refs.switchPopup.close();
			},
			//打开选择重复
			switchRepeat(value) {
				if (value.detail.value) {
					this.$store.commit("repeatAdd/SwitchRepeact", value.detail.value)
					this.$refs.switchPopup.open()
				} else {
					this.$store.commit("repeatAdd/SwitchRepeact", value.detail.value)
				}
			},
			// 结束重复选择完成
			endRepeatSuccess() {
				this.endOpenShow = true;
				this.$store.commit("repeatAdd/endRepeact", true)
				this.$refs.endPopup.close();
			},
			//取消结束重复
			endBack() {
				if (this.endOpenShow) {
					this.$store.commit("repeatAdd/endRepeact", true)
				} else {
					this.$store.commit("repeatAdd/endRepeact", false)
				}
				this.$refs.endPopup.close()
			},
			//编辑结束重复
			editEndRepeat() {
				this.$refs.endPopup.open()
			},
			//打开结束重复
			endRepeat(value) {
				if (value.detail.value) {
					this.$store.commit("repeatAdd/endRepeact", value.detail.value)
					this.$refs.endPopup.open()
				} else {
					this.$store.commit("repeatAdd/endRepeact", value.detail.value)
				}
			},
			changeyear() {
				this.isyear = true;
			},
			prev() {
				if (this.isyear) {
					this.$refs.years.prev()
				} else {
					this.$refs.calendar.subMonth()
				}
			},
			next() {
				if (this.isyear) {
					this.$refs.years.next()
				} else {
					this.$refs.calendar.addMonth()
				}
			},
			getyear(v) {
				let time = v.year + '-' + v.month;
				// vm.items.splice(indexOfItem, 1, newValue)
				this.switchTime.yearMonth = moment(time).format("YYYY年MM月");
				this.typelist.splice(0, 1, this.switchTime.yearMonth)
				this.currentTime = time;
				this.templates = {
					years: moment(time).format("YYYY-MM")
				}
				this.templates.date = moment(time, 'YYYY-MM-DD').format('YYYY年MM月');
				uni.setStorageSync("templates", this.templates);

				let year = moment(time).format("YYYY-MM");
				let a = this.filterWeekName(moment(year + '-' + this.switchTime.monthDayWeek.split("/")[1]).format(
					'YYYY-MM-DD'));
				console.log(a, "看看我")
				this.switchTime.monthDayWeek = moment(time).format("MM") + '/' + this.switchTime.monthDayWeek.split("/")[1] + '/' +
					(a ? a : '')
				this.typelist.splice(1, 1, this.switchTime.monthDayWeek)
				this.$store.commit("repeatAdd/setFormdulDefaultindex", 1);

			},
			//选择日期时滚动年月周改变
			dchange(e) {
				let result = moment(e).format("YYYY年MM月");
				this.switchTime.yearMonth = result;
				this.typelist.splice(0, 1, this.switchTime.yearMonth)
				let year = moment(e).format("YYYY-MM");
				let week = null;
				let a = this.filterWeekName(moment(year + '-' + this.switchTime.monthDayWeek.split("/")[1]).format(
					'YYYY-MM-DD'));
				this.switchTime.monthDayWeek = moment(e).format("MM") + '/' + this.switchTime.monthDayWeek.split("/")[1] + '/' + (a ?
					a : '')
				this.typelist.splice(1, 1, this.switchTime.monthDayWeek)
			},
			// 改变的日期
			dayChange(date) {
				if (date) {
					let {
						time
					} = this.templates;
					this.templates = {
						day: moment(date.fullDate).format('MM-DD'),
						week: this.filterWeekName(date.fullDate),
						years: moment(date.fullDate).format('YYYY-MM-DD'),
						dates: date.fullDate,
						date: moment(date.fullDate).format('YYYY-MM')
					}
					this.switchTime.monthDayWeek = moment(date.fullDate).format("MM/DD") + '/' + this.filterWeekName(moment(date.fullDate)
						.format(
							'YYYY-MM-DD'))
					this.typelist.splice(1, 1, this.switchTime.monthDayWeek)
					uni.setStorageSync("templates", this.templates);
					this.currentTime = moment(date.fullDate).format("YYYY-MM-DD");
					this.classShow = false;
					let week = null;
					this.switchTime.monthDayWeek = moment(date.fullDate).format("MM/DD") + '/' + this.filterWeekName(moment(date.fullDate)
						.format(
							'YYYY-MM-DD'))
					this.typelist.splice(1, 1, this.switchTime.monthDayWeek);
					this.$store.commit("repeatAdd/setFormdulDefaultindex", 2);
				}
			},
			// 改变的月份
			monthChange(data) {
				console.log('2', data);
				let a = moment(data.date, 'YYYY/MM/DD').format('YYYY年MM月')
				this.templates.date = a;
				uni.setStorageSync("templates", this.templates)
			},
			// 设置时间
			setDate(val) {
				if (val) {
					this.currentTime = moment(val, 'YYYY-MM-DD').format('YYYY-MM-DD')
				} else {
					this.currentTime = moment().format('YYYY-MM-DD');
				}
				console.log('设置日期', this.currentTime)
			},
			// 设置选择范围
			setRange() {
				this.range = {
					rangeStart: '2020-8-10', //设置标记范围开始，yyyyMM-dd
					rangeEnd: '2019-8-20' //设置标记范围结束，yyyyMM-dd
				}
			},
			setRangeMode() {
				this.rangeMode = !this.rangeMode;
			},
			rangeChange(data) {
				console.log('3', data)
			},
			// 新日里
			btnleftchose(item, index) {
				this.$store.commit("repeatAdd/delLiftList", item)
			},
			//关闭添加备注
			addNoteBack() {
				this.$refs.addNotePopup.close()
			},
			//备注完成
			addNoteSucess() {
				this.$refs.addNotePopup.close()
			},
			//选择提醒取消
			remindBack() {
				this.$refs.remindPopup.close()
			},
			//选择提醒完成
			remindScuess() {
				this.$refs.remindPopup.close()
			},
			btnrightchose(item, index) {
				this.optionId = item.ids
				switch (item.ids) {
					case 1:
						const _this = this;
						uni.chooseLocation({
							success: function(res) {
								let obj = {
									ids: item.ids,
									data: {
										latitude: res.latitude,
										longitude: res.longitude,
										name: res.address,
									}
								}
								_this.$store.commit("repeatAdd/pushData", obj)
								_this.$store.commit("repeatAdd/getPushItem", obj)
							},
							fail() {
								console.log("获取失败");
							}
						});
						break;
					case 2:
						this.$refs.remindPopup.open()
						break;
					case 3:
						this.$refs.pptUser.open()
						break;
					case 4:
						this.$refs.addNotePopup.open()
						break;
					default:
						console.log('没有找到调到哪里')
				}

			},
			// 开始
			bindtemstart(e) {
				this.$store.commit("repeatAdd/setTimeData", {
					startTime: e.detail.value
				})
			},
			// 结束
			bindtemend(e) {
				this.$store.commit("repeatAdd/setTimeData", {
					endTime: e.detail.value
				})
			},
			//时间点
			bindTimeChange(e) {
				this.$store.commit("repeatAdd/setTimeData", {
					timePoint: e.detail.value
				})
			},
			btncheck(val, i) {
				this.$store.commit("repeatAdd/btncheck", {
					val,
					i
				})
				this.sumtime(i)
			},
			btns(val, i) {
				this.$store.commit("repeatAdd/btns", {
					val,
					i
				})
			},
			btncourse(item) {
				this.templatesdata.defaucourse = item.name;
				this.saverval(7, item);
				this.btns(false, 1)
			},

			dayschange(e) {
				let a = moment(e).format('YY-MM-DD')
				console.log('days', a);
			},
			btnchosename(item) {
				let ele = this.checkdata.find((Ele) => {
					if (Ele.id == item.detail.value) {
						return Ele
					}
				})
				this.templatesdata.defaupublic = ele.name;
				this.saverval(8, ele);
				this.btns(false, 2)
				console.log(item);
			},
			changeMonth() {
				this.classShow = !this.classShow;
				this.setDate()
			},
			// 输入日期判断是周几
			filterWeekName(date) {
				this.classShow = false;
				const newDate = new Date(date.replace(/-/g, '/'));
				const weekday = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
				return weekday[newDate.getDay()];
			},

			Class(e) {
				if (e) {
					let date = e.fullDate;
					// let week = moment(date).weekday();
					this.templates = {
						day: moment(date).format('MM/DD'),
						week: this.filterWeekName(date),
						date,
					}
				}
				uni.setStorageSync("templates", this.templates)
			},
			changetype(i, ele) {
				this.formdul.defaultindex = i;
				this.$store.commit("repeatAdd/setTimeData", {
					typeIndex: i
				})
				this.classShow = false;
				this.sumtime(i)
			},
			sumtime(i) {
				if (i == 0) {
					this.templatesdata.time = this.timeindex;
				} else if (i == 1) {
					this.templatesdata.time = this.temstart + '至' + this.temend
					console.log(this.templatesdata.time);
				} else {
					this.templatesdata.time = ''
				}
			},
			onclick() {

			},
			confirm() {

			}
		}
	}
</script>

<style lang="scss" scoped>
	.contactBox {
		display: flex;
		justify-content: flex-start;
		align-items: center;

		.contactBorder {
			height: 48rpx;
			border-radius: 50%;
			text-align: center;
			line-height: 48rpx;
			font-size: 20rpx;
			background-color: #4A83F1;
			width: 48rpx;
			margin-left: 8rpx;
		}
	}

	.mymedia {
		background-color: #FFFFFF;
		height: 100vh;
		width: 100%;
		// position: relative;
		border: 1rpx solid red;
		box-sizing: border-box;
	}

	.overflowText {
		font-size: 24rpx;
		color: #999999;
		opacity: 1;
	}

	// 时间段
	.PeriodTime1 {
		width: 160rpx;
		height: 61rpx;
		display: flex;
		border-radius: 10rpx;
		justify-content: space-between;
		align-items: center;
		background-color: #3B3A3F;
		border: 1px solid transparent;
	}

	.PeriodTime1Ipt1 {
		width: 50%;
	}

	.colon {
		transform: translateX(-30px);
	}

	.switchTime {
		font-size: $today-fontSize24;
	}

	.iconIptBox {
		display: flex;
		align-items: center;
		border-bottom: 0.5px solid rgba(102, 102, 102, 0.2);
	}

	.numberTimeEnter1 {
		width: 100%;
		height: 50rpx;
		color: rgba(255, 255, 255, 1);
		text-align: center;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 147rpx;
		font-size: 22rpx;

		.timeinput {
			background-color: #3B3A3F;
			height: 50rpx;
			width: 160rpx;
			border-radius: 10rpx;
		}

		.timeinput:nth-child(1) {
			margin-right: 48rpx;
		}

		.timeinput:nth-child(2) {
			margin-left: 48rpx;
		}
	}

	.numberTimeEnter {
		width: 120rpx;
		height: 50rpx;
		background-color: rgba(59, 58, 63, 1);
		color: rgba(255, 255, 255, 1);
		text-align: center;
		margin: 0 auto;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
	}

	.switchTimeData {
		width: 100%;
		padding: 0 159rpx;
		height: 60rpx;
		display: flex;
		justify-content: space-between;
		border-radius: 10rpx;
		margin: 16rpx 0;
		margin-bottom: 20rpx;

		.timeItem {
			width: 125rpx;
			height: 60rpx;
			background-color: #26252A;
			color: #999999;
			text-align: center;
			line-height: 60rpx;
		}


		.timeItemActive {
			color: #4A83F1;
			border-radius: 10rpx;
			background-color: rgba(242, 242, 242, .1);
		}
	}

	/deep/ uni-radio::before,
	uni-checkbox::before {
		// display: none;
	}

	.fontSize {
		font-size: 40rpx;
	}

	.remindFontSize {
		font-size: 48rpx;
	}

	.overflowText {
		white-space: nowrap;
		text-overflow: ellipsis;
		width: 400rpx;
		overflow: hidden;
	}

	/deep/ .input-placeholder {
		color: rgba(153, 153, 153, 1);
		font-size: $today-fontSize32;
	}

	.addBox {
		background-color: $today-bg-color;
	}

	.m_header_top {
		color: $today-add-textColor;
	}

	.iconsize2 {
		font-size: 40rpx;
	}

	.openRange {
		width: 100%;
		display: flex;
		height: 100%;
		justify-content: space-evenly;
	}

	.openRangeIem {
		width: calc(100% / 3);
	}

	/deep/ .uni-radio-input {
		width: 20rpx;
		height: 20rpx;
		border-radius: 50%;
	}

	/deep/ .uni-radio-input-checked {
		width: 20rpx;
		height: 20rpx;
		background-color: rgb(0, 122, 255) !important;
		border-color: rgb(0, 122, 255) !important;
	}

	.allDay {
		text-align: center;
		border-top: 1px solid #DEDEDE;
		padding-top: 20rpx;
		font-size: 22rpx;
	}

	.radioBox {
		display: flex;
		height: 100%;
		width: 100%;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 0 80rpx;

		.radioItem {
			height: 100%;
			display: flex;
			width: 280rpx;
			margin: 16rpx 0;
			white-space: nowrap;
		}

	}

	.itemP {
		width: 80rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 104rpx;
		// padding: 22rpx;
		border-radius: 50%;
		border: 2px solid transparent;
	}

	.itemP:nth-child(1) {
		margin-left: 0;
	}

	.itemP:nth-child(5) {
		margin-left: 0;
	}

	.inputBox {
		display: flex;
		justify-content: space-between;
	}

	.icon-item {
		width: 150rpx;
		height: 150rpx;
		border-radius: 50%;
		background-color: red;
		text-align: center;
		line-height: 150rpx;
	}

	@font-face {
		font-family: 'iconfont';
		/* project id 2191229 */
		src: url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.eot');
		src: url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.eot?#iefix') format('embedded-opentype'),
			url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.woff2') format('woff2'),
			url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.woff') format('woff'),
			url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.ttf') format('truetype'),
			url('//at.alicdn.com/t/font_2191229_0ysoonqc1ux.svg#iconfont') format('svg');
	}

	.colorOk {
		width: 100%;
		display: flex;
		justify-content: flex-end;
	}

	.colorBox {
		width: 100%;
		height: 200rpx;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
	}

	.colorItem {
		width: 36rpx;
		height: 36rpx;
		display: block;
		border-radius: 50%;
	}

	.itemP::before {
		border: 2px solid transparent;
	}

	.itemP:hover::before {
		border-top-color: #4A83F1;
		border-right-color: #4A83F1;
		border-bottom-color: #4A83F1;
		transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s;
	}

	.itemP::after {
		border: 0rpx solid transparent;
	}

	.itemP:hover::after {
		border-top: 2px solid #4A83F1;
		border-left-width: 2px;
		border-right-width: 2px;
		-webkit-transform: rotate(270deg);
		transform: rotate(270deg);
		transition: border-left-width 0s linear 0.35s, -webkit-transform 0.4s linear 0s;
		transition: transform 0.4s linear 0s, border-left-width 0s linear 0.35s;
		transition: transform 0.4s linear 0s, border-left-width 0s linear 0.35s, -webkit-transform 0.4s linear 0s;
	}

	.itemP::before,
	.itemP::after {
		border-radius: 100%;
	}

	.itemP {
		border-radius: 100%;
		box-shadow: none;
		box-sizing: border-box;
		font-size: inherit;
		position: relative;
		vertical-align: middle;
	}

	.itemP::before,
	.itemP::after {
		box-sizing: inherit;
		content: '';
		position: absolute;
		width: 100%;
		height: 100%;
	}

	.itemP:nth-child(1) {
		margin-left: 0;
	}

	.btnSuccess {
		width: 100%;
		position: absolute;
		bottom: 100rpx;
		z-index: 999;
	}

	.contentBox {
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 16rpx;
		// background-color: $today-bg-color;
		color: $today-add-textColor;

		.change {
			display: flex;
			justify-content: space-between;
		}

		.title {
			font-size: $today-fontSize32;
			font-family: PingFang SC;
			white-space: nowrap;
			font-weight: 400;
			color: #121212;
			opacity: 1;
			margin: 0 16rpx 0 18rpx;
		}

		.iconsize1 {
			font-size: 40rpx;
		}

		.datetimeshow {
			position: relative;
			min-height: 800rpx;

			.timeyears {
				// position: absolute;
				// top: 0;
				// z-index: 20;
				// 	border: 1px solid red;
			}

			.month {
				// border: 1px solid red;
				position: absolute;
				top: 0;
				z-index: 10;
			}
		}

	}

	.oncetime {
		display: flex;
		margin-top: 16rpx;
		padding: 0 16rpx;
		box-sizing: border-box;
		flex-direction: column;
		justify-content: center;
		width: 100%;
		min-height: 60rpx;
		background-color: $today-add-switchColor;
		color: $today-add-textColor;
		opacity: 1;
		border-radius: 15rpx;
		justify-content: center;

		.chosetimehidden {
			height: 0;
			opacity: 0.5;
			overflow: hidden;
			transition: all .3s;
		}

		.chosetime {
			transition: all .5s;
			height: auto;
			opacity: 1;
			display: flex;
			flex-direction: column;
			padding: 16rpx 0;

			// 公开范围
			.public {
				display: flex;
				justify-content: space-around;

				.item {
					text-align: center;
					opacity: 1;
					border-radius: 10rpx;
				}

				.defauitem {
					background: #707070;
				}
			}

			// 我的日程表
			.childlist {
				padding: 16rpx 25rpx 0;
				border-top: 1rpx solid #696969;
				display: flex;
				justify-content: center;

				.childbox {
					width: 100%;
					display: flex;
					height: 100%;

					// justify-content:flex-start;
					.defauboxitem {
						background-color: #696969;
						border-radius: 15rpx;
					}

					.boxitem {
						// margin-top: 16rpx;
						align-self: flex-start;
						width: 33%;
						width: 100%;
						display: flex;

						.txt {
							margin-left: 10rpx;
						}
					}
				}
			}

			.daytime {
				font-weight: bold;
				display: flex;
				justify-content: center;
				color: #315FFA;
			}

			.vdatabox {
				width: 228rpx;
				height: 61rpx;
				opacity: 1;
				border-radius: 10rpx;
				line-height: 61rpx;
				color: rgba(102, 102, 102, 1);
				font-size: $today-fontSize32;
			}

			.defultbox {
				background: #3B3A3F;
				color: rgba(243, 243, 243, 1);
				width: 125px;
			}

			.timedata {

				padding: 16rpx 70rpx;
				display: flex;
				display: flex;
				align-items: center;
				justify-content: center;
				border-top: 1px solid #DEDEDE;
			}

			.centertxt {
				margin: 0 48rpx;
				font-size: 24rpx;
			}

			.itemdata {
				text-align: center;
				line-height: 50rpx;
				background: $today-bg-color;
				opacity: 1;
				border-radius: 10rpx;
				width: 120rpx;
				height: 50rpx;
				position: relative;

				.timesolid {
					position: absolute;
					left: 50%;
					transform: translateX(-50%);
					// border: 1rpx solid red;
				}

				.timeinput {
					text-align: right;
					// text-indent: 2rem;
					line-height: 50rpx;
					height: 50rpx;
					padding: 0 6rpx;
					letter-spacing: 10rpx;
				}
			}



			.addmethod {
				margin: 10rpx 0;
				padding: 0 16rpx;
				display: flex;
				justify-content: space-between;
				width: 100%;
				background-color: #26252A;

				text {
					text-align: center;
					border-radius: 10rpx;

				}
			}
		}

		.text {
			color: #666;
			height: 40rpx;
			line-height: 40rpx;
			margin-right: 10rpx;
			margin-top: 6rpx
		}

		.column {
			border-bottom: 1rpx solid rgba(102, 102, 102, 0.2);
			padding-bottom: 10rpx;
		}

		.defultbox {
			width: 32rpx;
			height: 32rpx;
		}

		.itemcnt {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 88rpx;

			.time1 {
				display: flex;
				align-items: center;
				flex: 2;
				font-size: 24rpx;
				width: 80%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;

				.title {
					color: $today-add-textColor;
				}
			}

			.time2 {
				flex: 1;
				display: flex;
				justify-content: center;
				display: flex;
				align-items: center;

				.title {
					color: $today-add-textColor;
				}
			}

			.downup {}
		}

	}

	.oncetime:nth-child(1) .itemcnt:nth-child(1) {
		border-bottom: 1px solid rgba(102, 102, 102, .2);
	}

	.oncetitle {

		border-radius: 15rpx;
		width: 100%;
		height: 161rpx;
		background-color: $today-add-switchColor;
		opacity: 1;
		margin-top: 16rpx;

		.myinput {
			height: 80rpx;
			padding: 0 16rpx;
			// border-bottom: 1rpx solid rgba(102, 102, 102, .2);
			box-sizing: border-box;
		}

		.box {
			padding: 0 100rpx;
			height: 88rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;
			width: 100%;

			text {
				margin-left: 10rpx;
			}

			.itemicon {
				display: flex;
			}

			.itemcolor {
				display: flex;
				align-items: center;
			}
		}
	}
</style>
